//
//  HomeWebViewController.swift
//  weibo19
//
//  Created by Arvin on 15/11/22.
//  Copyright © 2015年 Arvin. All rights reserved.
//

import UIKit
import MBProgressHUD

class HomeWebViewController: UIViewController, UIWebViewDelegate {
    
    var urlStr: String?
    var web = UIWebView()
    
    override func loadView() {
        view = web
        web.delegate = self
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        if let url = NSURL(string: urlStr ?? "") {
            let request = NSURLRequest(URL: url)
            
            web.loadRequest(request)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func webView(webView: UIWebView, didFailLoadWithError error: NSError?) {
        MBProgressHUD.showError(errorMessage)
        MBProgressHUD.hideHUD()
    }
    
    func webViewDidFinishLoad(webView: UIWebView) {
        MBProgressHUD.hideHUD()
    }

    func webViewDidStartLoad(webView: UIWebView) {
        MBProgressHUD.showMessage("正在加载网络")
    }
}
